//
// Created by EDZ on 2022/2/23.
//
#include "include.h"
#include "gramma_constexpr.h"
#include <iostream>

void func_gramma_constexpr() {
    std::cout << "\n";
    std::cout << "my_is_const<int>::value = " << (my_is_const<int>::value) << "\n";
    std::cout << "my_is_const<const int>::value = " << my_is_const<const int>::value;
    std::cout << "\n";
}

//{{{
//显式声明为constexpr类型
template<typename T>
constexpr auto addTo(T i) {
    return [i](auto j) { return i + j; };
}

constexpr auto add5 = addTo(5);

template<unsigned N>
class SomeClass {
public:
    SomeClass() : _m(N) {
        printf("AddTo(5)=%d\n", _m);
    }

    int getM() const {
        return (int)_m;
    }

private:
    unsigned _m;
};


int func_compute_in_compile_time() {
    //在编译期常量中使用
    SomeClass<add5(22)> someClass27;
    return someClass27.getM();
}
//}}}
